<?php
/**
 * 钻石投票模块处理程序
 *
 * @author 天涯织梦
 * @url http://bbs.we7.cc/
 */
defined('IN_IA') or exit('Access Denied');

class Tyzm_diamondvoteModuleProcessor extends WeModuleProcessor {
	public function respond() {
		$content = $this->message['content'];
		//这里定义此模块进行消息处理时的具体过程, 请查看微擎文档来编写你的代码
		$rid = $this->rule;
		$sql = "SELECT title,description,thumb,status,starttime FROM " . tablename('tyzm_diamondvote_reply') . " WHERE `rid`=:rid LIMIT 1";
		$row = pdo_fetch($sql, array(':rid' => $rid));

		if ($row == false) {
			return $this->respText("活动已取消...");
		}

		if ($row['isshow'] == 1) {
			return $this->respText("活动暂停，请稍后...");
		}

		if ($row['starttime'] > time()) {
			return $this->respText("活动未开始，请等待...");
		}

		return $this->respNews(array(
			'Title' => $row['title'],
			'Description' => $row['description'],
			'PicUrl' => toimage($row['thumb']),
			'Url' => $this->createMobileUrl('index', array('rid' => $rid)),
		));
	}
}

